import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:flutter_base/user/app_user_manager.dart';

class SharedKey {
  static String get deviceId => 'device_id';

  static String get account => 'account'.toMD5;

  static String get password => 'password'.toMD5;

  static String get token => 'app_user_token'.toMD5;

  static String get userInfo => 'app_user_Info'.toMD5;

  static String get loginTime => 'app_user_login_time'.toMD5;

  /// 手机号登录
  static String get loginPhone => "login_phone".toMD5;

  /// 软键盘高度
  static String get keyboardHeight => "keyboard_height".toMD5;

  static String get readingProgress => 'reading_progress_';

  static String get firstLaunch => "first_launch".toMD5;

  /// 搜索历史
  static String get searchHistory => "search_history".addUid.toMD5;

  /// 座驾开关
  static String get vehicleSwitch => "vehicle_switch".addUid.toMD5;

  /// 礼物特效开关
  static String get giftSpecial => "gift_special".addUid.toMD5;

  /// 震动提醒
  static String get shakeRemind => "shake_remind".addUid.toMD5;

}

extension StringMd5Extension on String {
  String get addUid =>
      this + (AppUserManager().user.value?.uid?.toString() ?? "");

  // String get addUid => this + '123'.toString();

  String get toMD5 => md5.convert(utf8.encode(this)).toString();

  String get toBase64Encode => base64Encode(utf8.encode(this));

  String get toBase64Decode => const Utf8Decoder().convert(base64Decode(this));
}
